//
//  SQNoticeViewController.m
//  pai
//
//  Created by pro on 14-10-29.
//  Copyright (c) 2014年 linjunjing. All rights reserved.
//

#import "SQNoticeViewController.h"
#import "SQMainViewController.h"

@interface SQNoticeViewController ()

@end

@implementation SQNoticeViewController

@synthesize scrollview = _scrollview;
@synthesize label = _label;
@synthesize submitbutton = _submitbutton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //公告
    UIView* ntview =[[UIView alloc]init];
    ntview.frame = CGRectMake(10, 40, 300, 400);
    [ntview setBackgroundColor:[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.5]];
    [self.view addSubview:ntview];
    
    UILabel* title = [[UILabel alloc]init];
    title.text = @"公告";
    [title setFont:[UIFont systemFontOfSize:30]];
    title.frame = CGRectMake(100, 10, 100, 50);
    [ntview addSubview:title];
    
    //公告内容
    _scrollview = [[UIScrollView alloc] init];
    //[scrollview setBackgroundColor:[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.5]];
    //[scrollview setBackgroundColor:[UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.5]];
    _scrollview.frame = CGRectMake(20, 50, 280, 280);
    _scrollview.pagingEnabled = NO;
    _scrollview.delegate = self;
    _scrollview.bounces = YES;
    [ntview addSubview:_scrollview];
    
    //按钮
    UIButton* submitbutton = [[UIButton alloc]initWithFrame:CGRectMake(100, 340, 100, 40)];
    [submitbutton setTitle:@"确定" forState:UIControlStateNormal];
    [submitbutton.layer setCornerRadius:4.0];
    [submitbutton setBackgroundColor:[UIColor redColor]];
    [submitbutton addTarget:self action:@selector(onActionClickfd:) forControlEvents:UIControlEventTouchDown];
    [ntview addSubview:submitbutton];
    
    //获取公告
    [self getcontent];
}

-(void)getcontent
{
    [self shownotice];
}

-(void)shownotice
{
    //显示内容
    NSString* str = @"\n欢迎使用搂客\n\n\n版本信息：V1.01:\n版本功能：XXXXXXXXX\n版本新增：XXXXXXXXXXX\n规则修改：\n1:XXXXXXXXXXXX\n2:XXXXXXXXXXXX\n3:XXXXXXXXXXXX\n4:XXXXXXXXXXXX\n请仔细阅读\n";
    UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    [label setNumberOfLines:0];
    [label setFont:[UIFont systemFontOfSize:16]];
    [label setTextColor:[UIColor redColor]];
    [label setText:str];
    CGSize size = [label.text sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:CGSizeMake(270, 3000)];
    NSLog(@"%f",size.height);
    [label setFrame:CGRectMake(0, 0, size.width, size.height)];
    [_scrollview addSubview:label];
    NSLog(@"%@",label.text);
    _scrollview.contentSize = CGSizeMake(label.frame.size.width, label.frame.size.height);
}

-(void)onActionClickfd:(UIButton *)button
{
    //确定
    NSLog(@"onActionClickfd");
    //跳转到主页
    SQMainViewController* main = [[SQMainViewController alloc]init];
    [self.navigationController pushViewController:main animated:NO];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
